//// demo_prog/Chapter3/lec4_demo_check_tip.c
// 使用格式字符将输出对齐的示例
// 宽度默认是以英文字符计数的
#include <stdio.h>

int main(void)
{
    printf("==== 输出对齐的收银小票 ====\n");
    printf("%-25s%10s%12s\n", "ITEM", "COUNT", "PRICE");
    printf("%-25s%10d%12.1f\n", "Huawei Mate60 Pro", 5, 5999.0);
    printf("%-25s%10d%12.1f\n", "Airplane C919", 1, 193993.0);
    printf("%-25s%10d%12.1f\n", "Apple", 100, 3.0);

    printf("==== 输出不对齐的收银小票 ====\n");
    printf("%s,%s,%s\n", "Item", "Count", "Price");
    printf("%s,%d,%f\n", "Huawei Mate60 Pro", 5, 5999.0);
    printf("%s,%d,%f\n", "Airplane C919", 1, 193993.0);
    printf("%s,%d,%f\n", "Apple", 100, 3.0);
    return 0;
}